/**
 * Copyright (C) 2021 - 2031 O-Cubes Co., Ltd.
 */

/****************************************************************
 *  @file    pmu.h
 *  @brief   PMU driver header file
 *  @version v1.0
 *  @date    03. Apr. 2023
 *  @author  gonght
 ****************************************************************/

#ifndef __PMU_H__
#define __PMU_H__

#include "io.h"
#include "bits.h"
#include "mem_map_table.h"

#ifdef __cplusplus
extern "C" {
#endif

#define PMU_AON_BASE                      MEM_MAP_PMU_BASE_ADDR
#define PMU_AON_IMC_REG                   PMU_AON_BASE
#define PMU_AON_ICR_REG                   (PMU_AON_BASE + 0x4)
#define PMU_AON_ISR_REG                   (PMU_AON_BASE + 0x8)
#define PMU_AON_MIS_REG                   (PMU_AON_BASE + 0xC)
#define PMU_AON_PVD_FALL_INT_POS          0
#define PMU_AON_PVD_RISE_INT_POS          1

#define PMU_AON_SLEEP_P_REG               (PMU_AON_BASE + 0x18)
#define PMU_AON_TRIMING_SEL_REG           (PMU_AON_BASE + 0x30)
#define PMU_AON_BAT_MODE_REG              (PMU_AON_BASE + 0x40)

#define PMU_ACTIVE_BASE                   (MEM_MAP_PMU_BASE_ADDR + 0x800)
#define PMU_ACTIVE_PVD_LV_REG             (PMU_ACTIVE_BASE + 0x8)
#define PMU_ACTIVE_TRIMING_SEL_REG        (PMU_ACTIVE_BASE + 0x18)
#define PMU_ACTIVE_PVD_EN_LV_REG          (PMU_ACTIVE_BASE + 0x2C)
#define PMU_ACTIVE_EFUSE_EN_REG           (PMU_ACTIVE_BASE + 0x30)

enum triming_sel {
	CFG_DATA,
	EFUSE_DATA,
};

typedef void (*PMU_CALLBACK) (void *ptr);

void pmu_aon_register_callback(PMU_CALLBACK pwron_cb, PMU_CALLBACK pwroff_cb);
void pmu_aon_enter_battery_mode(void);
void pmu_active_pvd_lv_cfg(uint32_t lv);
void pmu_init(void);

#ifdef __cplusplus
}
#endif

/** @} */

#endif /* __PMU_H__ */

